#include<bits/stdc++.h>
using namespace std;
struct node{
	int d,v,a;
	bool f=0;
	int x;
};
node car[3020];
int p[3020];
bool k[30][30];
int vis[30];
bool s(int dis,int v,int a,int lim){
	if (dis<0) return false;
	if (a<0){
		if (v*v<dis*a*2) return false;
	}
	int vn=v*v+2*a*dis;
	if (vn>lim*lim) return true;
	else return false;
}
bool c=0;
void work(int x,int y,int n,int m){
	if (c==1) return ;
	bool c1=1;
	for (int i=1;i<=n;i++){
		if (vis[i]==0&&car[i].f==1){c1=0;break;}
	}
	if (c1==1){
		c=1;
		return ;
	}
	if (y==0) return ;
	if (x>m) return ;
	for (int i=x;i<=m;i++){
		for (int j=1;j<=n;j++){
			if (k[i][j]==1) vis[j]++;
		}
		work(i+1,y-1,n,m);
		for (int j=1;j<=n;j++){
			if (k[i][j]==1) vis[j]--;
		}
		work(i+1,y,n,m);
	}
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while (T--){
		memset(p,0,sizeof(p));
		int sum=0;
		bool f1=1,f2=1;
		int n,m,L,V;
		cin>>n>>m>>L>>V;
		for (int i=1;i<=n;i++){
			cin>>car[i].d>>car[i].v>>car[i].a;
			if (car[i].a<=0) f1=0;
			if (car[i].a!=0) f2=0;
		}
		car[n+1].a=0;car[n+1].d=0;car[n+1].f=0;car[n+1].v=0;car[n+1].x=0;
		for (int i=1;i<=m;i++) cin>>p[i];
		for (int i=1;i<=n;i++){
			if (car[i].a<0){
				for (int j=m;j>=1;j--){
					if (s(p[j]-car[i].d,car[i].v,car[i].a,V)){
						sum++;
						car[i].f=1;
						car[i].x=j;
						break;
					}
				}
			}
			else {
				for (int j=1;j<=m;j++){
					if (s(p[j]-car[i].d,car[i].v,car[i].a,V)){
						sum++;
						car[i].f=1;
						car[i].x=j;
						break;
					}
				}
			}
		}
		cout<<sum<<" ";
		if (sum==0){
			cout<<m<<endl;
			continue;
		}
		if (n<=20){
			c=0;
			memset(k,0,sizeof(k));
			for (int i=1;i<=n;i++){
				if (car[i].a<0) {
					for (int j=car[i].x;j>=1;j--){
						if (p[j]<car[i].d) break;
						k[j][i]=1;
					}
				}
				else {
					for (int j=car[i].x;j<=m;j++) k[j][i]=1;
				}
			}
			for (int i=1;i<=m;i++){
				memset(vis,0,sizeof(vis));
				work(1,i,n,m);
				if (c==1) {cout<<m-i<<endl;break;}
			}
			if (c==0) cout<<m-3<<endl;
		}
		if (n>20&&(f1==1||f2==1)){
			if (f1==1||f2==1) cout<<m-1<<endl;
		}
	}
	return 0;
	fclose(stdin);
	fclose(stdout);
}
